package src.ten;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class CollectionDemo {

    public static void main(String[] args) {
        String a="A",b="B",c="C",d="D",e="E";
        List<String> list = new LinkedList<>();
        list.add(a);
        list.add(b);
        list.add(c);
        Iterator<String> firstIterator = list.iterator();
        System.out.println("修改前集合的元素是：");
        while (firstIterator.hasNext()){
            System.out.println(firstIterator.next()+" ");
        }
        list.set(0,b);
        list.add(c);
        Iterator<String> iterator = list.iterator();
        System.out.println();
        System.out.println("修改后集合中的元素是：");
        while (iterator.hasNext()){
            System.out.println(iterator.next()+" ");
        }

        System.out.println();
        System.out.println(list.indexOf("B"));
        System.out.println(list.lastIndexOf("B"));
    }
}
